{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bb1d3d59-5daa-409e-b9b4-2b624979b7ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "# File: walkthrough.ipynb\n",
    "# Code: Claude Code and Codex\n",
    "# Review: Ryoichi Ando (ryoichi.ando@zozo.com)\n",
    "# License: Apache v2.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7beca30c-0ee6-4f4a-b949-61687352364f",
   "metadata": {},
   "outputs": [],
   "source": [
    "from frontend import App\n",
    "\n",
    "# create an app for this walkthrough demonstration\n",
    "app = App.create(\"walkthrough\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d78a0f7-60c8-4e0c-9a50-a87e443cba59",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np  # noqa\n",
    "\n",
    "# create a 2D parametric curve with sinusoidal pattern\n",
    "N = 500\n",
    "P = []\n",
    "for i in range(N):\n",
    "    t = 2.0 * np.pi * i / N\n",
    "    r = 0.85 * np.cos(10 * t) + 1\n",
    "    x, y = r * np.cos(t), r * np.sin(t)\n",
    "    P.append([x, y])\n",
    "P = np.array(P)\n",
    "\n",
    "# plot the curve\n",
    "app.plot.create().curve(P)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3e85f5fc-1981-4eba-9b80-b2cd483b07d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# triangulate the curve to create a 2D mesh\n",
    "V, F = app.mesh.create.tri(P).triangulate()\n",
    "\n",
    "# plot the triangulated mesh\n",
    "app.plot.create().tri(V, F)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7b59c317-6ac9-4d38-b700-5049b5a70da2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# clear previous assets\n",
    "app.asset.clear()\n",
    "\n",
    "# create and plot an armadillo tetrahedral mesh\n",
    "V, F, T = (\n",
    "    app.mesh.preset(\"armadillo\").decimate(19000).tetrahedralize().normalize()\n",
    ")\n",
    "\n",
    "# plot the tetrahedral mesh\n",
    "app.plot.create().tet(V, T)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
